<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
    <link href="style/authority/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="style/authority/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="scripts/authority/commonAll.js"></script>
    <script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>
    <script type="text/javascript" src="scripts/artDialog/artDialog.js?skin=default"></script>
    <title>信息管理系统</title>
    <script type="text/javascript">
        function getMyDate(str) {
            var oDate = new Date(str),
                oYear = oDate.getFullYear(),
                oMonth = oDate.getMonth() + 1,
                oDay = oDate.getDate(),
                oHour = oDate.getHours(),
                oMin = oDate.getMinutes(),
                oSen = oDate.getSeconds(),
                // oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+ getzf(oMin) +':'+getzf(oSen);//最后拼接时间
                oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay);//最后拼接时间
            return oTime;
        };

        //补0操作
        function getzf(num) {
            if (parseInt(num) < 10) {
                num = '0' + num;
            }
            return num;
        }


        /** 用户角色   **/
        var userRole = '';

        /** 普通跳转 **/
        function jumpNormalPage(page) {
            $("#submitForm").attr("action", "house_list.html?page=" + page).submit();
        }

        function del(id) {
            $.ajax({
                type: "get",
                url: '/info/del/' + id,
                dataType: "json",
                success: function (data) {
                    if (data.success) {
                        window.location.reload()
                    }else{
                        alert(data.message);
                    }
                }
            });
        }
        /** 输入页跳转 **/
        function jumpInputPage(totalPage) {
            // 如果“跳转页数”不为空
            if ($("#jumpNumTxt").val() != '') {
                var pageNum = parseInt($("#jumpNumTxt").val());
                // 如果跳转页数在不合理范围内，则置为1
                if (pageNum < 1 | pageNum > totalPage) {
                    art.dialog({
                        icon: 'error',
                        title: '友情提示',
                        drag: false,
                        resize: false,
                        content: '请输入合适的页数，\n自动为您跳到首页',
                        ok: true,
                    });
                    pageNum = 1;
                }
                $("#submitForm").attr("action", "house_list.html?page=" + pageNum).submit();
            } else {
                // “跳转页数”为空
                art.dialog({
                    icon: 'error',
                    title: '友情提示',
                    drag: false,
                    resize: false,
                    content: '请输入合适的页数，\n自动为您跳到首页',
                    ok: true,
                });
                $("#submitForm").attr("action", "house_list.html?page=" + 1).submit();
            }
        }
        function searchList() {
            var pageNum = 1;
            var pageSize = 10;
            var search = $("#search").val();
            getData(pageNum, pageSize,search);
        }

    </script>

    <script>
        var pageNum = 1;
        var pageSize = 10;
        var search = $("#search").val();
        getData(pageNum, pageSize,search);

        /** 用户列表数据 **/
        function getData(pageNum, pageSize,search) {
            if(search == undefined){
                search="";
            }
            $.get("/info/getList/" + pageNum + "/" + pageSize + "?search=" + search, function (data) {
                $("#destTable tr:gt(0)").remove();
                if (data.success == true) {
                    $("#totalPages").html(data.message.totalPages);
                    $("#number").html(data.message.number + 1);
                    $("#totalElements").html(data.message.totalElements);
                    if (data.message.content != null) {
                        $.each(data.message.content, function (index, value) {
                            var html = $("#moban").html();
                            html = html.replace(/{bano}/g, value.bano);
                            html = html.replace(/{czf}/g, value.czf);
                            html = html.replace(/{address}/g, value.address);
                            html = html.replace(/{zpf}/g, value.zpf);
                            html = html.replace(/{yt}/g, value.yt);
                            html = html.replace(/{zpflx}/g, value.zpflx);
                            html = html.replace(/{starttime}/g, getMyDate(value.starttime));
                            html = html.replace(/{id}/g, value.id);
                            $("#destTable").append(html);
                        });
                    }
                }
            });
        };
    </script>
    <style>
        .alt td {
            background: black !important;
        }
    </style>
</head>
<body>
<input name="search" id="search" value='' style="width: 290px;height: 25px;padding: 3px 5px;background: #FFFFFF;border: #dddddd 1px solid;border-radius: 3px;outline: none;margin: 0 32px;" placeholder="请输入备案号"/>
<input type="button" value="搜索" onclick="searchList();" style='width: 80px;height: 30px;line-height: 30px;text-align: center;border-style: double;cursor: pointer;padding: 0 0 0 0;font-family: "Microsoft YaHei", "微软雅黑", "sans-serif"; background: url(../../images/login/btn.jpg) 0px -1px no-repeat; border-color: buttonface; border-image: initial;' />
<form id="submitForm" name="submitForm" action="" method="post">
    <input type="hidden" name="allIDCheck" value="" id="allIDCheck"/>
    <div id="container">
        <div class="ui_content">
            <div class="ui_tb">
                <table id="destTable" class="table" cellspacing="0" cellpadding="0" width="100%" align="center"
                       border="0">
                    <tr>
                        <th>备案号</th>
                        <th>出租方</th>
                        <th>地址</th>
                        <th>租赁方</th>
                        <th>用途</th>
                        <th>租赁方类型</th>
                        <th>开始时间</th>
                        <th>操作</th>
                    </tr>
                </table>
                <table id="moban" style="display:none">
                    <tr>
                        <td>{bano}</td>
                        <td>{czf}</td>
                        <td>{address}</td>
                        <td>{zpf}</td>
                        <td>{yt}</td>
                        <td>{zpflx}</td>
                        <td>{starttime}</td>
                        <td>
                            <a href="house_edit.html?id={id}" class="edit">编辑</a>
                            <a href="javascript:del('{id}');">删除</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="ui_tb_h30">
                <div class="ui_flt" style="height: 30px; line-height: 30px;">
                    共有
                    <span class="ui_txt_bold04" id="totalElements"></span>
                    条记录，当前第
                    <span class="ui_txt_bold04" id="number"></span>
                    /
                    <span id="totalPages"></span>
                    页
                </div>
                <div class="ui_frt">
                    <input id="pPage" type="button" value="上一页" class="ui_input_btn01" onclick="prePage();"/>
                    <input id="nPage" type="button" value="下一页" class="ui_input_btn01" onclick="nextPage();"/>
                </div>
            </div>
        </div>
    </div>
</form>

<script language=JavaScript>
    /** 下一页 **/
    function nextPage() {
        var curPage = $("#number").text();
        var last = $("#totalPages").text();
        if (curPage != last) {
            getData(Number(curPage) + 1, pageSize);
        }
    }

    /** 上一页 **/
    function prePage() {
        var curPage = $("#number").text();
        if (curPage != 1 && curPage > 1) {
            getData(Number(curPage) - 1, pageSize);
        }
    }

</script>
</body>
</html>
